package com.winai.launcher.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.winai.launcher.R;
import com.winai.launcher.base.BaseRecAdapter;
import com.winai.launcher.base.BaseRecViewHolder;
import com.winai.launcher.bean.CommonBean;

public class WifiAdapter extends BaseRecAdapter <CommonBean, WifiAdapter.ViewHolder> {
    private Context mContext;
    private WifiItemAdapter linkedAdapter;
    private WifiItemAdapter unlinkedAdapter;

    public WifiAdapter(Context mContext, WifiItemAdapter linkedAdapter, WifiItemAdapter unlinkAdapter) {
        this.mContext = mContext;
        this.linkedAdapter = linkedAdapter;
        this.unlinkedAdapter = unlinkAdapter;
    }

    @Override
    public void onHolder(ViewHolder holder, CommonBean commonBean, int position) {
        TextView wifiTitle = holder.getView(R.id.str_wifiTitle);
        wifiTitle.setText(commonBean.getStr());

        RecyclerView innerRecyclerView = holder.getView(R.id.recyclerView_inner);
        innerRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 1));
        if (commonBean.getId().equals("0")) {
            innerRecyclerView.setAdapter(linkedAdapter);
        } else if (commonBean.getId().equals("1")) {
            innerRecyclerView.setAdapter(unlinkedAdapter);
        }
    }

    @Override
    public ViewHolder onCreateHolder() {
        return new ViewHolder(getViewByRes(R.layout.item_set_wifi));
    }

    class ViewHolder extends BaseRecViewHolder {
        ViewHolder(View itemView) {
            super(itemView);
        }
    }
}